package com.example.tbsdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import pub.devrel.easypermissions.EasyPermissions;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String[] perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE};
        if (!EasyPermissions.hasPermissions(this, perms)) {//权限申请
            EasyPermissions.requestPermissions(this, "需要访问手机存储权限！", 10086, perms);
        }
        View btn = findViewById(R.id.btn);
        final EditText et_url = findViewById(R.id.et_url);
        et_url.setText("http://blackwhale.f3322.net:12306/zjl/111.doc");//默认的office文件的地址，最好自己先用浏览器验证地址是否存在
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, TBSActivity.class);
                intent.setType(et_url.getText().toString());
                startActivity(intent);
            }
        });
    }
}
